#ifndef CH_TABCTRLBUTTONS_H
#define CH_TABCTRLBUTTONS_H

#pragma once

class CHTabCtrlButtons;
class CHWndHook;

#define CH_IDC_TAB_CLOSE                53789

class AFX_EXT_CLASS CHTabCtrlButton
{
public:
	CHTabCtrlButton (DWORD wStyle);
	
	void Draw(CDC* pDC, COLORREF clrButton);
	DWORD Click(CHTabCtrlButtons* pWnd, CPoint pt, BOOL bRepeat = FALSE);
	void SetRect(CRect rc);
	CRect GetRect();
	BOOL PtInRect(POINT pt) const;
	void CheckForMouseOver (CWnd* pWnd, CPoint pt);
	void SetEnable(BOOL bEnable);

	CRect m_Rect;
	DWORD m_wStyle;
	CTabCtrl* m_pTabCtrl;
};

//////////////////////////////////////////////////////////////////////

AFX_INLINE CHTabCtrlButton::CHTabCtrlButton(DWORD wStyle) {
	m_wStyle = wStyle;
}
AFX_INLINE void CHTabCtrlButton::SetRect (CRect rc) {
	m_Rect = rc;
}
AFX_INLINE CRect CHTabCtrlButton::GetRect() {
	return m_Rect;
}
AFX_INLINE BOOL CHTabCtrlButton::PtInRect (POINT pt) const {
	return m_Rect.PtInRect (pt) != 0;
}

//////////////////////////////////////////////////////////////////////
// CHTabCtrlButtonsis a CWnd derived class.  It is internal used in CHTabCtrlBase class.
//
class AFX_EXT_CLASS CHTabCtrlButtons: public CWnd
{
public:
	CHTabCtrlButtons();
	~CHTabCtrlButtons();
	
	BOOL Create(CTabCtrl* pParent);
	
	int GetWidth();
	
	void ShowButtons(BOOL bShow);
	BOOL ShowButtons();
	void Refresh();
	void SubclassTabButtons(CWnd* pWnd);

private:
	CRect AdjustRect();
private:
	CHTabCtrlButton m_btnClose;
	CHTabCtrlButton m_btnLeft;
	CHTabCtrlButton m_btnRight;

	int m_dwFlags;
	CTabCtrl* m_pTabCtrl;
	BOOL m_bShow;

	HWND m_hwndSubclassed;
	HWND m_hwndPrimary;

private:

	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnMouseLeave();
	afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);

	DECLARE_MESSAGE_MAP()

	friend class CHTabCtrlBase;
};


#endif //CH_TABCTRLBUTTONS_H
